module extraepd.dexpd.value;
enum VAL {
  NULL,
  INT,
  FLOAT,
  STR,
  WSTR,
  DSTR,
  BOOL,
  USR
}
struct DVal {
  VAL type;
  union {
    long Int;
    double Float;
    string Str;
    wstring WStr;
    dstring DStr;
    bool Bool;
    struct{
        void *Ptr;
        TypeInfo Ptrs;
    }
  }
  this ( T ) ( T a ) {

  static if ( is ( T: long ) ) {
        type = VAL.INT;
        Int = a;
        return;
      }
  else static if ( is ( T: double ) ) {
        type = VAL.FLOAT;
        Float = a;
        return;
      }
  else static if ( is ( T: dstring ) ) {
        type = VAL.DSTR;
        DStr = a;
        return;
      }
  else static if ( is ( T: wstring ) ) {
        type = VAL.WSTR;
        WStr = a;
        return;
      }
  else static if ( is ( T: string ) ) {
        type = VAL.STR;
        Str = a;
        return;
      }
  else static if ( is ( T: bool ) ) {
        type = VAL.BOOL;
        Bool = a;
        return;
      }
    else static if ( isPointer! ( T ) ) {
        if ( a !is null ) {
            Ptr = cast ( void * ) a;
            Ptrs = Typeid ( T );
            type = VAL.USR;
          }
        else type = VAL.NULL;

      }
  }
  T to ( T )(){

  static if ( is ( T: long ) ) {
        return Int;
      }
  else static if ( is ( T: double ) ) {
        return Float;
      }
  else static if ( is ( T: dstring ) ) {
        return Dstr;
      }
  else static if ( is ( T: wstring ) ) {
        return Wstr;
      }
  else static if ( is ( T: string ) ) {
        return Str;
      }
  else static if ( is ( T: bool ) ) {
        return Bool;
      }
    else static if ( isPointer! ( T ) ) {
        return cast(T) Ptr;
      }
  }
}

template isPointer ( U, T: U * ) {
  enum isPointer = true;
}

template isPointer ( T ) {
  enum isPointer = false;
}

DVal DValAs ( T ) ( T arg ) {

}
